package com.homedo.microservice.open.service.gateway.manager.web.controller;

import com.homedo.common.util.Detect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@RestController
public class IndexController {
    @Autowired
    private HttpServletRequest httpServletRequest;

    @RequestMapping("/")
    public ModelAndView index() {
        String redirect = "redirect:/pages/index.html";
        String _redirect = httpServletRequest.getParameter("_redirect");
        if (Detect.notEmpty(_redirect)) {
            redirect = "redirect:" + _redirect;
        }

        ModelAndView mv = new ModelAndView(redirect);

        return mv;
    }
}
